package com.yi.mall.order.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yi.mall.common.model.DTO.orderDTO;
import com.yi.mall.common.model.OrderInfo;
import com.yi.mall.common.model.OrderQuery;
import com.yi.mall.common.utils.ResponseEnum;
import com.yi.mall.common.utils.Result;
import com.yi.mall.order.service.impl.OrderInfoServiceImpl;
import com.yi.mall.order.service.impl.OrderServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderInfoServiceImpl orderService;
    @Autowired
    private OrderServiceImpl orderService1;
    @DeleteMapping("/{id}")
    public Result removeById(@PathVariable String id) {
        orderService.removeById(id);
        return Result.success(ResponseEnum.SUCCESS);
    }
    @PostMapping("/save")
    public Result save(@RequestBody orderDTO orderVO) throws Exception {
        OrderInfo orderInfo = orderService1.save(orderVO);
        return Result.success(ResponseEnum.SUCCESS,orderInfo);
    }
    @GetMapping("/page")
    private Result page( OrderQuery query) {
        Page page = orderService.page(query);
        return Result.success(ResponseEnum.SUCCESS,page);
    }
}
